Guard global rate limiting against the FastAPI 0.137+ regression - #86
Closed
amrtgaber wants to merge 2 commits into
Closed
Guard global rate limiting against the FastAPI 0.137+ regression#86amrtgaber wants to merge 2 commits into
amrtgaber wants to merge 2 commits into
Conversation
FastAPI >=0.137 resolves included routers' routes lazily, which breaks slowapi's SlowAPIMiddleware enforcement of default_limits on undecorated routes — every /v1 route here — while all existing tests stay green (slowapi issue #281, fix PR #282 open upstream). Add a canary test asserting the 60/min default actually bites on an undecorated route (verified to fail on fastapi 0.140.7 and pass on the current lock), a limiter-reset fixture so its request count doesn't leak across tests, and resolver constraints holding fastapi below 0.136 and starlette below 1.0 until a fixed slowapi release ships.
Refresh the lockfile within the rate-limit guard constraints (fastapi stays 0.135.x, starlette 0.52; OpenTelemetry, structlog 26, wrapt 2 and the rest move to latest), update the ruff pre-commit hook from v0.8.6 to v0.16.0 with the ruff-check id and apply its fixes, and move to Python 3.14 across .python-version, requires-python, ruff target-version, and the Docker base image; all compiled dependencies ship cp314 wheels. Pin the Dockerfile uv stage, bump CI to checkout@v7 and setup-uv@v9.0.0 (no v9 alias tag exists), and add weekly grouped Dependabot updates. The dev compose Postgres stays on 16 pending a coordinated production upgrade.
Contributor
Author
|
Superseded — content landed via the restore PR after the stacked-rebase mistake. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
FastAPI ≥0.137 materializes included routers' routes lazily, which silently disables slowapi's
SlowAPIMiddlewareenforcement ofdefault_limitson undecorated routes — which is every/v1route in this service. All 26 existing tests stay green when it happens (slowapi issue #281, open fix PR #282).This PR makes the failure impossible to ship unnoticed:
/v1/armorsucceed, the 61st must 429. Empirically verified to fail on fastapi 0.140.7 and pass on the current lock./and/healthnever 429.fastapi<0.136,starlette<1.0with the unpin condition documented: a slowapi release containing the #282 fix (Dependabot will surface the slowapi bump).A separate stacked PR applies the toolchain/Python 3.14 refresh on top of this protection.